<script setup lang="ts">
import zh_CN from "ant-design-vue/lib/locale-provider/zh_CN";
import "moment/dist/locale/zh-cn";
import { useRoute } from "vue-router";
import useUserStore from "@/stores/modules/user";
import CryptoJS from "crypto-js";
const userStore = useUserStore();
const route = useRoute();

import { GetUserInfo } from "@/api/main";
const decrypt = (encryptedUsername: any) => {
  let key = "hrwzc00000";
  // 使用AES解密算法对用户名和密码进行解密
  let decryptedUsername = CryptoJS.AES.decrypt(encryptedUsername, key).toString(
    CryptoJS.enc.Utf8
  );
  return decryptedUsername;
};
// 获取当前页面的URL
const url = window.location.href;
// 查找empId参数的起始位置
const startIndex = url.indexOf("empId=");

if (startIndex !== -1) {
  // 计算参数值的起始位置（在empId=之后）
  const valueStartIndex = startIndex + "empId=".length;
  // 查找参数值结束的位置（可以是#或者字符串末尾）
  const endIndex =
    url.indexOf("#", valueStartIndex) !== -1
      ? url.indexOf("#", valueStartIndex)
      : url.length;
  const empId = url.substring(valueStartIndex, endIndex);
  userStore.empid = decrypt(empId);

  GetUserInfo({ empid: userStore.empid }).then((response) => {
    userStore.yn = response.data.yn;
    userStore.userInfo = response.data;
  });
}
</script>

<template>
  <a-config-provider :locale="zh_CN">
    <RouterView />
  </a-config-provider>
</template>

<style scoped></style>
